/****************************************************
          File Name:17-2.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon Jan 19 17:35:07 2015
*****************************************************/

#include<iostream>
#include<fstream>
#include<cstdlib>
using namespace std;

int main(int argc, char *argv[])
{
    if(argc < 2)
    {
        cerr << argv[0] << "filename" << endl;
        exit(EXIT_FAILURE);
    }

    char ch;
    ofstream fout(argv[1], ios_base::out | ios_base::app);

    cout << "input somethig (CTRL+D to quit)" << endl;
    while(cin.get(ch))
    {
        fout << ch;
    }

    fout.close();
    return 0;
}
